{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "73e2396c",
   "metadata": {},
   "source": [
    "# FIR滤波器结构：级联型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "3dd710f6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAbgAAAEoCAYAAAAqrOTwAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAgTklEQVR4nO3df5BddX3/8eeLZYk7oRAgK5J8xQwtTQdLENwvQyrQqGAQgeaLtWHAL6VYEy2tVpmAKfFbRRAkQi1QqLFRGZyGH2nMiEg30BIIFgwbAwkwbh2oid0QWEqWTJiVxM37+8c5N7lZ7yZ77+7de/dzXo+ZHe4993PP+3P2s7kvzjmfe44iAjMzs9Qc1OgOmJmZ1YMDzszMkuSAMzOzJDngzMwsSQ44MzNLkgPOzA5IkhrdB7NqOeDM6kDSBZKOGka7g8vDQ9JBkg6TdGH+fIKkqyW1lLWZOOi5JLWWPT9D0vIq+3uVpD/aT5MbJZ1RzTrNGs0BZ5aT9CVJOyRtLfuZm7+2WtI5ZW2/K+kNSb2SXpL08bLXDgW+Dhwk6RJJGyR1S3pC0jpJK8rKfgp4VdKzkn4GbALOBz4n6d3A2UBHRAyUvedbwIuSfi6pC+gDbpZ0qaTrgbfyn9I2fekA230qcCrwg/00uxG4SdJh+1uXWTNxwJnt6/aIeEfZz737aXt1RLQDHwPukDS5tBz4GjAN2AV8Eng4Ik4HlgLPlFYQEbcDDwLzgS/lr/8UWAW8H/hr4MeSzi57z8XAN4FrgYuA9RHxGWBnXm83UM0VHL4MfDb2c9WHiNgG3AJcWcV6zRrKAWc2QhGxDvgFcJyk84CPAtuAW4EdQCtZ+EAWWqsqrOY7wPX5498CtgJnAr/M13UUgKQZkv4COA04gyxcj8mXTai275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+AIFGG/Y87f+Q+BU4FFJ7dWOeTIBV/D7z50GnCdpbf4HUOsl2MaFwR/yBRv7AWAuULptRlHGfvAH/UUUYMwj4o6IeDh/2g78mmKMN2T/8/b5iLge6AQ+QJVjnkzAkV0W7L788Sr2Xui5CJ4GzoqIU4FW4NwG96feBn/Iz6IgYx8R2wdd9q4QY1/hg/7jFGTMASTNBI4AHqYA4w0QEY9FxFOSziTbi5tNlWOeUsBNBHryx68DRzewL2NtQ0S8nD/uApL8v9mSCh/yHvtM8mNf9kH/Swoy5pKOBG4DLqd44y2y/5ndBgRVjnlKATece9Sl6m5JJ0lqAeYAzza4P2PNY1+AsR/0QV+IMZd0CHA/sDAiNlGg8QaIzBXABuAPqHLMU/qjKPL9564F7gaeAZ6MiEca250x57FPfOwrfNAXZcw/AZwCXCNpNfA8BRhvAElXS7o0fzoJuJEqxzyZL3pLOgxYA/wb+f3nfIuetElaHRGzPPbpk/Rp4Kvs3WP5DvB5PObJyieT3QdMAJ4DFgKPU8WYJxNwsOcXcjbweERsbXR/bOx47IvHY1481Y55UgFnZmZWktI5ODMzsz0ccGZmliQHnJmZJckBZ2ZmSXLAmZlZkv4/DBjNyUVb84cAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "#libraries\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "from scipy import signal\n",
    "\n",
    "#parameters of defference equation\n",
    "A = 1;a = np.array([[1,0,0],[1,0,0]]) #denominator\n",
    "b = np.array([[1,1.72,0.81],[1,1.17,0.85]]) #numerator\n",
    "\n",
    "#input signal\n",
    "M = a.shape[0];N = 30\n",
    "delta = signal.unit_impulse(N) #unit sample signal\n",
    "y = np.ones(N) #unit step signal\n",
    "\n",
    "#FIR casfilter\n",
    "z1 = np.zeros((M+1,N));z2 = np.zeros((M+1,N));\n",
    "z1[0,:] = delta;z2[0,:] = y; \n",
    "for i in range(M): #循环滤波，计算最终结果\n",
    "    zi = signal.lfilter_zi(b[i,:],a[i,:])*0 #zero initial condition\n",
    "    z1[i+1,:],_ = signal.lfilter(b[i,:],a[i,:],z1[i,:],zi=zi);\n",
    "    z2[i+1,:],_ = signal.lfilter(b[i,:],a[i,:],z2[i,:],zi=zi);\n",
    "\n",
    "#plot\n",
    "fig,axs = plt.subplots(2,1,constrained_layout=True)\n",
    "axs[0].stem(A*z1[M,:],basefmt=\"\");axs[1].stem(A*z2[M,:],basefmt=\"\")\n",
    "plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签\n",
    "axs[0].set_title('FIR级联型h(n)');axs[1].set_title('FIR级联型y(n)')\n",
    "plt.show();fig.savefig('./fir_cas_sequence.png',dpi=500)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3bb59ba3",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
